-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't crash/terminate upon errors within chokidar #1020
Conversation
@DanTup Thanks for the PR. Could you please:
|
LGTM (after processing @sylvain-hamel 's comments). |
Thanks @DanTup |
I'm struggling to figure out how to test this. I've looked in both file_list specs and watcher specs but I can't find any similar tests that are testing watcher's interaction with chokidar. There are some tests in file_list that look like they're interacting with a mock filesystem (there's even a test Since my fix is in My best guess is that I need to add the mock fs to the watcher specs, and force it to error on stat (similar to the I'll update this PR with the other changes (style + commit message); but I'll need some guidance on getting a test in for this :( (Also FYI; |
Handle errors from chokidar and route them to the console. Previously, these unhandled errors (which are very common when editing in Visual Studio) would cause karma to terminate and all browsers to vanish. Fixes #959
@DanTup ur specs shld best fit here karma/test/unit/watcher.spec.coffee Line 50 in 438eb8d
|
@deepak1556 That's where I started adding tests; but none of the existing ones seem to interact with any chokidar events; so I'm unsure how best to do it. I need to force choikdar to throw (eg. tell it a file has modified that doesn't exist, so it throws when trying to stat the file). |
Even following those instructions and re-cloning, I still get the same lint issue. If I type It's only happening on some lines, which makes me wonder if the source files are bad, and those not seeing it are having them normalised on the way out? (I can move this lint stuff to another Issue to keep this PR on-topic if you want?) |
Yup a separate issue is better for lint. chokidar events needs to be supported on |
Raised #1030 for lint issue; will await further guidance for this PR on how best to deal with testing chokidar interaction. |
I'm ok with this without a unit test. The You could extract the wiring of chokidar with FileList into a separate function and then unit test it. (you could test that 1/ the events are forwarded to FileList, 2/ that the FileList calls are with the right context, 3/ that Chokidar errors are ignored/logged, etc...) |
It sounds like a bigger change than I think I could do well with my limited knowledge of all this; but I'm happy to come back and add a test if this "plumbing" for testing it is added later :) This has been manually tested well; removing the handler causes karma to intermittently crash and vanish when saving and adding it in stops the crash (I confirmed the chokidar error was still occurring by logging when it raised errors, to ensure it wasn't just fluke). |
Due to the way some editors save changes; Chokidar might throw an error
trying to stat a file that was created and then removed/renamed very
quickly. Previously this would just bring the entire Karma process down;
which seems rather unhelpful.